//
//  BaseTableViewController.swift
//  SinaWeibo
//
//  Created by 张洪毓 on 15/11/8.
//  Copyright © 2015年 张洪毓. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {
    
//    var userLogin = false
//    var userLogin = UserAccount.loadAccount() != nil
    var userLogin = UserAccountViewModel().userLogin

    var visitorLoginView: VisitorLoginView?
    
    override func loadView() {
        userLogin ? super.loadView() : loadVisitorLoginView()
    }
    
    private func loadVisitorLoginView() {
        visitorLoginView = VisitorLoginView()
        visitorLoginView?.visitorDelegate = self
        view = visitorLoginView
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorLogin")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorRegister")
    }
    
//MARk:  代理方法的实现
    func visitorLogin() {
        let navi = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(navi, animated: true, completion: nil)
        print("登录成功")
    }
    
    func visitorRegister() {
        print("注册成功")
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }
    
    
    
    
    
    
}
